package org.xue.snowmall.group.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.xue.snowmall.common.utils.PageUtils;
import org.xue.snowmall.common.utils.R;
import org.xue.snowmall.group.entity.GroupEntity;
import org.xue.snowmall.group.service.GroupService;

import java.util.List;
import java.util.Map;

/**
 * @author 小刘的小张
 * @version 1.0
 * @description: TODO
 * @date 2021/9/27 16:04
 */
@Controller
public class WebGroupController {

    @Autowired
    private GroupService groupService;

    @RequestMapping("/")
    public String groupList(Model model
            , @RequestParam Map<String, Object> params) {
        PageUtils<GroupEntity> pageUtils = groupService.queryPage(params);
        model.addAttribute("list",pageUtils);
        return "group";
    }

    @GetMapping("/createGroupOrder")
    @ResponseBody
    public R createGroupOrder(@RequestParam("gsmGroupId") Long gsmGroupId) {
        return groupService.createGroupOrder(gsmGroupId);
    }
}
